package tool

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

const (
	SUCCESS = 0  // 操作成功
	FAILED = 1   // 操作失败
)

func Success(ctx *gin.Context, data interface{}) {
	ctx.JSON(http.StatusOK, gin.H{
		"code": 0,
		"message": "success",
		"data": data,
	})
}

func Failed(ctx *gin.Context, message string) {
	ctx.JSON(http.StatusOK, gin.H{
		"code": FAILED,
		"message": message,
	})
}

func FailedWithData(ctx *gin.Context, message string, data interface{}) {
	ctx.JSON(http.StatusOK, gin.H{
		"code": FAILED,
		"message": message,
		"data": data,
	})
}


